import axios from 'axios'
let baseURL='http://121.42.230.80/api'
const token = sessionStorage.getItem('token')
const $http = axios.create({
    baseURL,
    headers:{
        'Authorization':token
    }
  })

 export const get = (url,params) => {
    params = params || {};
   return new Promise((resolve, reject) => {
   $http.get(url, {
        params,
   }).then(res => {
       if (res.status == 200) {
               resolve(res.data);
               console.log(Authorization);
       } else {
               reject(res.data.msg)
       }
       }).catch(error => {
               reject('网络异常');
           })
       })
   }

   export const post = (url, params) => {
       params = params || {};
       return new Promise((resolve, reject) => {
       $http.post(url, params).then(res => {
       if (res.status == 200) {
                resolve(res.data);
       } else {
                reject(res.data.msg);
       }
       }).catch(error => {
               reject('网络异常');
           })
       })
       }